<template>
  <view>
    <view>
      age：{{age}}
    </view>
    <view>
      username：{{username}}
    </view>
    <view>
      <button @click="updateAge">updateAge</button>
      <button @click="updateUsername">updateUsername带参数</button>
    </view>
  </view>
</template>

<script lang="ts">
import Vue from 'vue'
import {NumberUtils} from 'great-jsutils'

export default Vue.extend({
  methods: {
    updateAge(){
      this.$store.dispatch('updateAge');
    },
    updateUsername(){
      this.$store.dispatch('updateUsername', 'user'+NumberUtils.randomInt());
    }
  },
  computed: {
    age(){
      return this.$store.state.age
    },
    username(){
      return this.$store.state.username
    }
  }
})
</script>

<style scoped>

</style>
